import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import {Image, View} from '@tarojs/components'
import {APPLICATION_BACKGROUND} from "../../constants/api"
import {http} from "../../utils/http";
import HeaderBar from "../components/header-bar/header-bar";
import './index.scss'
import {vcmonitor} from "../../utils/tools";

export default class Index extends Component {
  state = {
    img: ''
  }

  async UNSAFE_componentWillMount() {
    vcmonitor(this)
    const res = await http.HGet(APPLICATION_BACKGROUND, {})
    if (res && res.data) {
      this.setState({
        img: res.data
      })
    } else {
      await Taro.redirectTo({url: '/other/carRental/list'})
    }
  }

  render() {
    const {img} = this.state;
    return (
      <View className='carRentalIndex'>
        <HeaderBar title='' color='#000' />
        <Image src={img} onClick={() => Taro.navigateTo({url: '/other/carRental/list'})} mode='aspectFill'
          style='width: 100%;height: 100vh;'
        />
      </View>
    );
  }
}
